class sysinit::ulimit {
  
  $max_openfile = $sysinit::max_openfile
  $max_process  = $sysinit::max_process
  
  file { '/etc/security/limits.local':
    ensure => present,
  }
  
  concat { 'limit':
    path  => '/etc/security/limits.conf',
    owner => 'root',
    group => 'root',
    mode  => '0644',
    warn  => true,
  }

  concat::fragment { 'limit_header':
    target => 'limit',
    source => 'puppet:///modules/sysinit/limits.conf',
    order  => '1',
  }
  
  concat::fragment { 'nofile':
    target  => 'limit',
    content => "*\t-\tnofile\t${max_openfile}\n",
    order   => '2',
  }
  
  concat::fragment { 'nproc':
    target  => 'limit',
    content => "*\t-\tnproc\t${max_process}\n",
    order   => '3',
  }
  
  concat::fragment { 'limit_footer':
    target => 'limit',
    source => '/etc/security/limits.local',
    order  => '99',
  }
}